home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1999 January: Mac OS SDK / Dev.CD Jan 99 SDK1.toast / Development Kits / Interfaces&Libraries / Universal / Interfaces / PInterfaces / Multiprocessing.p < prev    next >
Encoding:
Text File  |  1998-08-17  |  6.0 KB  |  204 lines  |  [TEXT/MPS ]

  1. {
  2.      File:        Multiprocessing.p
  3.  
  4.      Contains:    Multiprocessing interfaces
  5.  
  6.      Version:    Technology:    System 7.5
  7.                  Release:    Universal Interfaces 3.2
  8.  
  9.      Copyright:    © 1996-1998 by Apple Computer, Inc. and © 1995-1997 DayStar Digital, Inc.
  10.  
  11.      Bugs?:        For bug reports, consult the following page on
  12.                  the World Wide Web:
  13.  
  14.                      http://developer.apple.com/bugreporter/
  15.  
  16. }
  17. {$IFC UNDEFINED UsingIncludes}
  18. {$SETC UsingIncludes := 0}
  19. {$ENDC}
  20.  
  21. {$IFC NOT UsingIncludes}
  22.  UNIT Multiprocessing;
  23.  INTERFACE
  24. {$ENDC}
  25.  
  26. {$IFC UNDEFINED __MULTIPROCESSING__}
  27. {$SETC __MULTIPROCESSING__ := 1}
  28.  
  29. {$I+}
  30. {$SETC MultiprocessingIncludes := UsingIncludes}
  31. {$SETC UsingIncludes := 1}
  32.  
  33. {$IFC UNDEFINED __MACTYPES__}
  34. {$I MacTypes.p}
  35. {$ENDC}
  36. {$IFC UNDEFINED __CODEFRAGMENTS__}
  37. {$I CodeFragments.p}
  38. {$ENDC}
  39.  
  40.  
  41. {$PUSH}
  42. {$ALIGN POWER}
  43. {$LibExport+}
  44.  
  45. {$IFC TARGET_CPU_PPC }
  46.  
  47. CONST
  48.     MPLibrary_MajorVersion        = 1;
  49.     MPLibrary_MinorVersion        = 4;
  50.     MPLibrary_Release            = 1;
  51.     MPLibrary_DevelopmentRevision = 2;
  52.  
  53.  
  54. TYPE
  55.     MPTaskID = ^LONGINT;
  56.     MPQueueID = ^LONGINT;
  57.     MPSemaphoreID = ^LONGINT;
  58.     MPCriticalRegionID = ^LONGINT;
  59.     MPSemaphoreCount                    = UInt32;
  60.     MPTaskOptions                        = UInt32;
  61. {$IFC TYPED_FUNCTION_POINTERS}
  62.     TaskProc = FUNCTION(parameter: UNIV Ptr): OSStatus; C;
  63. {$ELSEC}
  64.     TaskProc = ProcPtr;
  65. {$ENDC}
  66.  
  67. {$IFC TYPED_FUNCTION_POINTERS}
  68.     MPRemoteProcedure = FUNCTION(parameter: UNIV Ptr): Ptr; C;
  69. {$ELSEC}
  70.     MPRemoteProcedure = ProcPtr;
  71. {$ENDC}
  72.  
  73. {$IFC TYPED_FUNCTION_POINTERS}
  74.     MPPrintfHandler = PROCEDURE(taskID: MPTaskID; format: ConstCStringPtr; args: va_list); C;
  75. {$ELSEC}
  76.     MPPrintfHandler = ProcPtr;
  77. {$ENDC}
  78.  
  79.  
  80. CONST
  81.     kDurationImmediate            = 0;
  82.     kDurationForever            = $7FFFFFFF;
  83.  
  84.     kMPNoID                        = 0;
  85.  
  86.  
  87. FUNCTION MPProcessors: UInt32; C;
  88. FUNCTION MPCreateTask(entryPoint: TaskProc; parameter: UNIV Ptr; stackSize: ByteCount; notifyQueue: MPQueueID; terminationParameter1: UNIV Ptr; terminationParameter2: UNIV Ptr; options: MPTaskOptions; VAR task: MPTaskID): OSStatus; C;
  89.  
  90. FUNCTION MPTerminateTask(task: MPTaskID; terminationStatus: OSStatus): OSStatus; C;
  91.  
  92. PROCEDURE MPExit(status: OSStatus); C;
  93.  
  94. FUNCTION MPCurrentTaskID: MPTaskID; C;
  95.  
  96. PROCEDURE MPYield; C;
  97.  
  98. FUNCTION MPCreateQueue(VAR queue: MPQueueID): OSStatus; C;
  99.  
  100. FUNCTION MPDeleteQueue(queue: MPQueueID): OSStatus; C;
  101.  
  102. FUNCTION MPNotifyQueue(queue: MPQueueID; param1: UNIV Ptr; param2: UNIV Ptr; param3: UNIV Ptr): OSStatus; C;
  103.  
  104. FUNCTION MPWaitOnQueue(queue: MPQueueID; VAR param1: UNIV Ptr; VAR param2: UNIV Ptr; VAR param3: UNIV Ptr; timeout: Duration): OSStatus; C;
  105.  
  106. FUNCTION MPCreateSemaphore(maximumValue: MPSemaphoreCount; initialValue: MPSemaphoreCount; VAR semaphore: MPSemaphoreID): OSStatus; C;
  107.  
  108.  
  109. FUNCTION MPWaitOnSemaphore(semaphore: MPSemaphoreID; timeout: Duration): OSStatus; C;
  110.  
  111. FUNCTION MPSignalSemaphore(semaphore: MPSemaphoreID): OSStatus; C;
  112.  
  113. FUNCTION MPDeleteSemaphore(semaphore: MPSemaphoreID): OSStatus; C;
  114.  
  115. FUNCTION MPCreateCriticalRegion(VAR criticalRegion: MPCriticalRegionID): OSStatus; C;
  116.  
  117. FUNCTION MPEnterCriticalRegion(criticalRegion: MPCriticalRegionID; timeout: Duration): OSStatus; C;
  118.  
  119. FUNCTION MPExitCriticalRegion(criticalRegion: MPCriticalRegionID): OSStatus; C;
  120.  
  121. FUNCTION MPDeleteCriticalRegion(criticalRegion: MPCriticalRegionID): OSStatus; C;
  122.  
  123. FUNCTION MPAllocate(size: ByteCount): LogicalAddress; C;
  124. PROCEDURE MPFree(object: LogicalAddress); C;
  125.  
  126. PROCEDURE MPBlockCopy(sourcePtr: LogicalAddress; destPtr: LogicalAddress; blockSize: ByteCount); C;
  127.  
  128. {*************************************************************************
  129.  *
  130.  *    MPTaskIsToolboxSafe() and MPRPC() were functions added by DayStar. 
  131.  *    The 1.4 MPLibrary exports the names with an underscore prefix. 
  132.  *    To work around this, #defines have been added to automatically
  133.  *    add the underscore.
  134.  *
  135.  }
  136.     MPTaskIsToolboxSafe() allows routines which are otherwise unaware that 
  137.     they are being called from an MP task to check to see if it is permissible
  138.     to make a call to the Macintosh toolbox.  (It is okay to make toolbox 
  139.     calls only if the routine is not being called from an MP task).
  140. }
  141. FUNCTION MPTaskIsToolboxSafe(task: MPTaskID): BOOLEAN; C;
  142. {
  143.     MPRPC() calls its MPRemoteProcedure parameter in the application's main 
  144.     thread when the app next calls WaitNextEvent, EventAvail, SystemTask, 
  145.     MPYield, MPWaitOnQueue, MPWaitOnSemaphore, or MPEnterCriticalRegion. The  
  146.     return value of the MPRemoteProcedure is returned as the result of MPRPC.  
  147.     The MPRemoteProcedure function can call any toolbox function except  
  148.     SystemTask (or anything that calls it).
  149. }
  150. FUNCTION MPRPC(theProc: MPRemoteProcedure; parameter: UNIV Ptr): Ptr; C;
  151.  
  152.  
  153. {*************************************************************************
  154.  *
  155.  *    The following routines were added by DayStar for debugging purposes.
  156.  *    You should not use these in shipping products.  You can tell which
  157.  *    functions are for debugging only because they begin with an underscore
  158.  *
  159.  }
  160. FUNCTION _MPIsFullyInitialized: BOOLEAN; C;
  161.  
  162. {
  163.     MPAllocateSys() does the same thing as MPAllocate() except the memory
  164.     is allocated from the system heap.
  165. }
  166. FUNCTION _MPAllocateSys(size: ByteCount): LogicalAddress; C;
  167.  
  168. FUNCTION _MPLibraryIsCompatible(versionCString: ConstCStringPtr; major: UInt32; minor: UInt32; release: UInt32; revision: UInt32): BOOLEAN; C;
  169. PROCEDURE _MPInitializePrintf(pfn: MPPrintfHandler); C;
  170. PROCEDURE _MPPrintf(format: ConstCStringPtr; ...); C;
  171.  
  172. {
  173.      MPDebugStr() works just like DebugStr() except that it is safe
  174.     to call it from an MP task.
  175. }
  176. PROCEDURE _MPDebugStr(msg: Str255); C;
  177. {
  178.  
  179.     MPStatusPString() and MPStatusCString() provide a way to translate an OSStatus
  180.     value returned from one of the MP API calls into either a Pascal string or a
  181.     C string.  Thus, if an MPLibrary function returns an error then the application
  182.     (not a task) could use the following:
  183.  
  184.     status = MPxxx( function_params );
  185.     DebugStr( MPStatusPString( status ) );
  186.     
  187. }
  188. FUNCTION _MPStatusPString(status: OSStatus): StringPtr; C;
  189. FUNCTION _MPStatusCString(status: OSStatus): ConstCStringPtr; C;
  190.  
  191. {$ENDC}  {TARGET_CPU_PPC}
  192.  
  193. {$ALIGN RESET}
  194. {$POP}
  195.  
  196. {$SETC UsingIncludes := MultiprocessingIncludes}
  197.  
  198. {$ENDC} {__MULTIPROCESSING__}
  199.  
  200. {$IFC NOT UsingIncludes}
  201.  END.
  202. {$ENDC}
  203.